/** @format */
import { services, checkParams, noCheckUser, preCheck } from '../decorator/common';
import { resultsModel } from '../sdk';
import { UserService, TemplateService,} from '../service';

export default class TemplateController {

  /**
   *  添加模版信息
   */
  @checkParams(['activityId'])
  @noCheckUser
  @services([TemplateService])
  async addTemplate(
    context: IContext<IParams>,
    { userInfo }: IControllerInfos,
    [templateService]: [TemplateService]
  ) {
    console.log(`login`, context, userInfo);
    const { data } = context;

    const res = await templateService.addTemplate(userInfo, data as ICommonTemplateInfo);
    return resultsModel.success(res);
  }

  /**
   *  获取模版信息
   */
  @checkParams(['activityId'])
  @noCheckUser
  @services([TemplateService])
  async getTemplateList(
    context: IContext<IParams>,
    { userInfo }: IControllerInfos,
    [templateService]: [TemplateService]
  ) {
    console.log(`login`, context, userInfo);
    const { data } = context;

    const res = await templateService.addTemplate(userInfo, data as ICommonTemplateInfo);
    return resultsModel.success(res);
  }
}
